package com.example.backblog.controller.system;

import cn.hutool.system.oshi.OshiUtil;
import com.alibaba.fastjson.JSONObject;
import com.example.backblog.apijson.DemoParser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/system")
public class SystemController {
    @GetMapping("/basic")
    public JSONObject  systemInformation(){
        long memTotal = OshiUtil.getMemory().getTotal();
        long memAvail = OshiUtil.getMemory().getAvailable();
        double cpuTotal = OshiUtil.getCpuInfo().getToTal();
        double cpuAvail = OshiUtil.getCpuInfo().getToTal();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("memTotal",memTotal);
        jsonObject.put("memAvail",memAvail);
        jsonObject.put("cpuTotal",cpuTotal);
        jsonObject.put("cpuAvail",cpuAvail);

        return DemoParser.extendSuccessResult(jsonObject);
    }

}
